$(function () {

    $(".inforTitle .step em:eq(2)").css("background", "rgb(255, 48, 48)");
    $(".inforTitle .schedule i:eq(1)").css("border-top-color", "rgb(255, 48, 48)");

    $("#passOld").focus(function () {
        $("#passOld").val("");
    })
    $("#passNew1").focus(function () {
        $("#passNew1").val("");
        $("#passNew2").val("");
    })
    $("#passNew2").focus(function () {
        $("#passNew2").val("");
    })

    $(".setnewpassword .inforSubmit button").click(function () {
        let passOld = $("#passOld").val();
        let passNew1 = $("#passNew1").val();
        let passNew2 = $("#passNew2").val();

        if(passOld === ""){
            alert("请输入原始密码!");
        } else if(passNew1 ===""){
            alert("请输入新密码!");
        }else if(passNew2 === ""){
            alert("请再次输入新密码!");
        }else if(passNew1 !== passNew2){
            console.log(passNew1+ "  " +passNew2);
            $("#hintInfo").html("两次密码不一致，请确认后再次输入");
        }else{
            console.log("准备发送请求");
            $.ajax({
                url: "/xiumiInput.do",
                type: "post",
                dataType: "json",
                data: {
                    "info" : localStorage.getItem("currentLoginUserPhone.aomall.com"),
                    "passOld" : passOld,
                    "passNew1" : passNew1
                },
                success: function (data) {
                    console.log(data.status);
                    console.log(data.message);
                    if(data.status === "true"){
                        window.location.href = "/WebContent/member/Member-xiumisuccess.html";
                    }else{
                        $("#passOld").val("");
                        $("#passNew1").val("");
                        $("#passNew2").val("");
                    }

                }
            })
        }
    })
})